package co.za.alicrity.exactcover;

import co.za.alicrity.exactcover.linkedlist.ListNode;

public class Node implements ListNode<Node>{
	
	private Node nextColumn;
	private Node prevColumn;
	private Node nextRow;
	private Node prevRow;
	private ColumnHeader header;
	
	private int row,col;

	public Node(int row, int col, ColumnHeader header) {
		super();
		this.row = row;
		this.col = col;
		this.header=header;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public int getCol() {
		return col;
	}

	public void setCol(int col) {
		this.col = col;
	}

	@Override
	public Node getNext() {
		return nextRow;
	}

	@Override
	public Node getPrevious() {
		return prevRow;
	}

	@Override
	public void setNext(Node node) {
		nextRow=node;
	}

	@Override
	public void setPrevious(Node node) {
		prevRow=node;
	}
	
	public String toString(){
		
			String n="(";
			if (prevColumn==null){
				n+="null";
			} else {
				n+="["+prevColumn.row+":"+prevColumn.col+"]";
			}
		n += "["+row+":"+col+"]";
		if (nextColumn==null){
			n+="null";
		} else {
			n+="["+nextColumn.row+":"+nextColumn.col+"]";
		}
		return n+")";
	}

	public Node getNextColumn() {
		return nextColumn;
	}

	public void setNextColumn(Node nextColumn) {
		this.nextColumn = nextColumn;
	}

	public Node getPrevColumn() {
		return prevColumn;
	}

	public void setPrevColumn(Node prevColumn) {
		this.prevColumn = prevColumn;
	}

	public Node remove() {
		return header.remove(this);
	}

	public void putBack() {
		header.putBack(this);
	}
	
	
	
	

}
